﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Kugar.MVC.MobileUI.WeUI
{
    public abstract class MobileWeUIPage : WebViewPage
    {
        public MobileWeUI WebUI { get; private set; }

        public override void InitHelpers()
        {
            base.InitHelpers();

            ViewContext.ViewBag.MobileWeUIPage = this;

            WebUI = new MobileWeUI(base.ViewContext);
        }

        public void EnablePullToRefresh(string onRefreshCallback)
        {
            ViewBag.OnRefreshCallback = onRefreshCallback;

        }

        public void EnableLoadingMore(string onLoadMoreCallback)
        {
            ViewBag.OnLoadMoreCallback = onLoadMoreCallback;
        }

        /// <summary>
        /// 返回MobileWeUILayout的路径
        /// </summary>
        public string DefaultLayoutPath => "~/Views/Shared/MobileWeUILayout.cshtml";
    }

    public abstract class MobileWeUIPage<TModel> : WebViewPage<TModel> where TModel : class
    {
        public override void InitHelpers()
        {
            base.InitHelpers();

            WebUI = new MobileWeUI(base.ViewContext);

            ViewContext.ViewBag.MobileWeUIPage = this;
        }

        public void EnablePullToRefresh(string onRefreshCallback)
        {
            ViewBag.OnRefreshCallback = onRefreshCallback;

        }

        public void EnableLoadingMore(string onLoadMoreCallback)
        {
            ViewBag.OnLoadMoreCallback = onLoadMoreCallback;
        }

        public MobileWeUI WebUI { get; private set; }

        /// <summary>
        /// 返回MobileWeUILayout的路径
        /// </summary>
        public string DefaultLayoutPath => "~/Views/Shared/MobileWeUILayout.cshtml";
    }
}